from typing import List

class Solution:
    def generateParenthesis(self, n: int) -> List[str]:
        def backtrack(current, open_count, close_count):
            if len(current) == 2 * n:
                result.append("".join(current))
                return

            if open_count < n:
                current.append('(')
                backtrack(current, open_count + 1, close_count)
                current.pop()

            if close_count < open_count:
                current.append(')')
                backtrack(current, open_count, close_count + 1)
                current.pop()

        result = []
        backtrack([], 0, 0)
        return result

# 获取用户输入的 n
n = int(input("请输入一个整数 n："))

# 创建 Solution 类的实例
solution = Solution()

# 调用 generateParenthesis 方法并打印结果
print(solution.generateParenthesis(n))